define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {
		/**
		 * 一键切换数据获取方式
		 * @param {Object} result
		 */
		function get_data_getbannerlist(result) {
			if(HTTP_ISLOGIC) {
				result = '{"success": true,"msg": "","result": {"associate": [' +
					'{"associate_id": 1,"associate_type": "type_A","image_id": "./img/upload/siwper-img00.png","d_order": 1},' +
					'{"associate_id": 2,"associate_type": "type_A","image_id": "./img/upload/siwper-img01.png","d_order": 2},' +
					'{"associate_id": 2,"associate_type": "type_A","image_id": "./img/upload/siwper-img02.png","d_order": 3}' +
					']},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		/**
		 * 一键切换数据获取方式
		 * @param {Object} result
		 */
		function get_data_detail(result) {
			if(HTTP_ISLOGIC) {
				result = '{"success": true,"msg": "",' +
					'"result": {"act_id": "001","name": "促销","start_time": "2017/01/01 09:00:00","end_time": "2017/01/31 09:00:00","create_group": true,"has_packets": true,"image": [{"id": "001","image": ""},{"id": "002","image": ""}],"brand_id": "001","cat_type": [{"id": "001"},{"id": "002"}]},' +
					'"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}

		function get_data_goods_introduce(result) {
			if(HTTP_ISLOGIC) {
				result = '{"success": true,"msg": "","result": {"store_count": "500","data": [' +
					'{"goods_id": 1,"name": "十字螺丝刀","introduce": "十字螺丝刀","price": 5.5,"mktprice": 8,"preprice": 5.5,"store_id": "WuJin_1",' +
					'"store_name": "五金一店","image": "./img/upload/pro-img02.jpg","storenumber": 100,"salenumber": 20,"personlimit": 3,"qq": "1234567","phone": "18912345678"},' +
					'{"goods_id": 2,"name": "一字螺丝刀","introduce": "一字螺丝刀","price": 5.5,"mktprice": 8,"preprice": 5.5,"store_id": "WuJin_1",' +
					'"store_name": "五金一店","image": "./img/upload/pro-img02.jpg","storenumber": 80,"salenumber": 10,"personlimit": 3,"qq": "1234567","phone": "18912345678"}]},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else
				return result;
		}

		function get_data_record_list(result) {
			if(HTTP_ISLOGIC) {
				result = '{"success": true,"msg": "","result": {"records": [' +
					'{"name": "张三","price": 10,"time": "2017/01/01 09:00:00"},' +
					'{"name": "李四","price": 20,"time": "2017/01/01 09:10:00"}]},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else
				return result;
		}

		function get_data_auction_view(result) {
			if(HTTP_ISLOGIC) {
				result = '{"success":true,"msg":"","result":{"act_id":"001","name":"拍卖车床","end_time":"2017/01/31 09:00:00","introduction":"最新德国科技，不可错过。","group_id":"123456789","image":[{"id":"001","image":"./img/upload/siwper-img00.png"},{"id":"002","image":"./img/upload/siwper-img01.png"},{"id":"003","image":"./img/upload/siwper-img02.png"}],"goods":{"id":"001","name":"德系车床","now_price":"500000","margin_price":"100000","add_price":"50000","participant":"11","hit_list":[{"name":"张三","price":"450000","time":"2017/01/31 08:00:00"},{"name":"李四","price":"150000","time":"2017/01/30 08:00:00"}]}},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else
				return result;
		}

		function get_data_auction_apply(result) {
			if(false) {
				result = '';
				return JSON.parse(result);
			} else
				return result;
		}
		//返回信息
		return {
			//获取轮播图
			getbannerlist: function(callback) {
				Http.post({
						method: 'homepage.banner.getbannerlist',
						picSize: 'CS',
						pagelimit: 8,
						nPage: 1
					},
					function(result) {
						//请求成功
						if(callback)
							callback(get_data_getbannerlist(result).result);
					},
					function(e) {
						//请求异常
					},
					function() {
						//请求完成，一般不做什么事情
					}
				);
			},
			//获取详细数据
			get_detail: function(act_id, callback) {
				Http.post({
					method: 'marketing.auction.detail',
					act_id: act_id
				}, function(result) {
					if(callback)
						callback(get_data_detail(result).result);
				}, function(err) {

				}, function() {

				});
			},
			goods_introduce: function(act_id, callback) {
				Http.post({
					method: 'goods.search.getlist',
					cat_type: 17,
					pagelimit: 8,
					nPage: 1,
					show_count: 5,					
					picSize: 'CS',
					act_id: act_id
				}, function(result) {
					if(callback)
						callback(get_data_goods_introduce(result).result);
				}, function(e) {

				}, function() {

				})
			},
			record_list: function(act_id, callback) {
				Http.post({
					method: 'marketing.auction.recordlist',
					act_id: act_id
				}, function(result) {
					if(callback)
						callback(get_data_record_list(result).result);
				}, function(e) {

				}, function() {

				})
			},
			auction_view: function(act_id,goods_id ,product_id, callback) {
				Http.post({
					method: 'marketing.auction.view',
					act_id: act_id,
					product_id: product_id,
					goods_id:goods_id,
					picSize: 'CS'
				}, function(result) {
					if(callback)
						callback(result,result.process_time);
				}, function(e) {

				}, function() {

				})
			},
			auction_apply: function(act_id, price, callback) {
				Http.post({
					method: 'marketing.auction.apply',
					act_id: act_id,
					price: price

				}, function(result) {
					if(callback)
						callback(result);
				})
			},
			pay_list:function(apply_id,act_id,callback){
				Http.post({
					method:'payment.bondpay.go_pay',
					apply_id:apply_id,
					act_id:act_id
				},function(result){
					if(callback)
					callback(result);
				})
			},
			get_article:function(id,callback){
				Http.post({
					method:'marketing.auction.get_article',
					id:id
				},function(result){
					if(callback)
					callback(result);
				})
			}
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Panicauctiondetail", factory);
});